package com.yunzai.chat.config;

import com.yunzai.chat.endpoint.ChatEndpoint;
import com.yunzai.onebot.service.IOneBotService;
import com.yunzai.secure.service.ITokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

@Configuration
@EnableWebSocket
public class ChatConfig {

    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter(); // 自动注册 @ServerEndpoint
    }

    @Autowired
    public void chatEndpoint(IOneBotService oneBotService, ITokenService tokenService) {
        ChatEndpoint.oneBotService = oneBotService;
        ChatEndpoint.tokenService = tokenService;
    }
}
